import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../../routes/xin_he_routes.dart';
import '../../../../utils/xh_styles.dart';
import '../../../../utils/xin_he_image.dart';
import '../../../shopping_car/models/xin_he_goods_model.dart';
import 'xin_he_apply_sale_after_list_logic.dart';

class XinHeApplySaleAfterListPage extends StatelessWidget {
  XinHeApplySaleAfterListPage({Key? key}) : super(key: key);

  final logic = Get.put(XinHeApplySaleAfterListLogic());
  final state = Get.find<XinHeApplySaleAfterListLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
            onPressed: (){
              Get.back();
              },
            icon: Container(
    padding: const EdgeInsets.only(left: 7),
    alignment: Alignment.centerLeft,
    child: const XinHeAssetImage(
    'assets/images/home/app_back_3.png',
    width: 9.5,
    height: 17,
    fit: BoxFit.cover,),
    )
        ),
          backgroundColor: Colors.white,
          shadowColor: Colors.transparent,
          title: Text('申请售后',style: TextStyle(color:XinHeColor('#222222'),fontSize: 17,fontWeight: FontWeight.w600)),
          centerTitle: true,
        ),
      body: ListView.builder(
        itemCount: 10,
          itemBuilder: (ctx,index){
          return Container(
            color: Colors.white,
            margin: const EdgeInsets.only(top:10),
            padding: const EdgeInsets.symmetric(horizontal: 15),
            child: Column(
              children: [
                SizedBox(
                  height: 44,
                  child: Row(children: [
                    const XinHeAssetImage('assets/images/cart/cart_unselected.png',width: 18,height: 18,),
                    SizedBox(width: 5,),
                    Text('欧若拉',style: TextStyle(color: XinHeColor('#282C2C'),fontSize: 13,fontWeight: FontWeight.w500),),
                    SizedBox(width: 3,),
                    const XinHeAssetImage('assets/images/cart/pay_arrow.png',width: 6,height: 10,),
                    Spacer(),
                    Text('退货',style: TextStyle(color: XinHeStyle.mainGreenColor,fontSize: 13,fontWeight: FontWeight.w600),),


                  ],),
                ),

                _goodsItemView(XinHeGoodsModel(),0),
                SizedBox(height: 5,),

                Container(
                  decoration: BoxDecoration(color: XinHeColor('#F2F2F2'),borderRadius: BorderRadius.circular(5)),
                  height: 27,
                  padding: EdgeInsets.symmetric(horizontal: 10),
                  alignment: Alignment.centerLeft,
                  child: RichText(text: TextSpan(children: [

                    TextSpan(
                      text: '退款成功',
                      style: TextStyle(
                        color:XinHeColor('#222222'),
                        fontSize: 12,
                        fontWeight: FontWeight.w500,
                      ),
                    ),

                    ///￥
                    TextSpan(
                      text: '退款',
                      style: TextStyle(
                        color:XinHeColor('#86898A'),
                        fontSize: 11,
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                    ///￥
                    TextSpan(
                      text: '￥',
                      style: TextStyle(
                        color: XinHeColor('#86898A'),
                        fontSize: 10,
                        fontWeight: FontWeight.w500,
                      ),
                    ),

                    ///
                    TextSpan(
                      text: '398.00',
                      style: TextStyle(
                        color: XinHeColor('#86898A'),
                        fontSize: 12,
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                  ]),),
                ),

                SizedBox(height: 16,),
                Row(children: [
                  Spacer(),
                  Container(
                    height: 30,
                    width: 75,
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(15),
                        border: Border.all(color: XinHeColor('#B9B9B9'),width: 0.5)
                    ),
                    child:  Text('删除订单',style: TextStyle(color: XinHeColor('#666666'),fontSize: 14),strutStyle: StrutStyle(forceStrutHeight: true),),
                  ),
                  const SizedBox(width: 10,),
                  GestureDetector(
                    onTap: (){
                      Get.toNamed(XinHeRoutes.orderDetail);
                    },
                    child: Container(
                      height: 30,
                      width: 75,
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        gradient: LinearGradient(colors: [ XinHeColor('##F89A30'), XinHeColor('#E84128')]),
                        borderRadius: BorderRadius.circular(15),
                      ),
                      child: Text('订单详情',style: TextStyle(color: Colors.white,fontSize: 14),strutStyle: const StrutStyle(forceStrutHeight: true)),
                    ),
                  ),

                ],),
                SizedBox(height: 16,),



              ],),);
        }
        ),
    );
  }

  Widget _goodsItemView(XinHeGoodsModel model,int index){
    return Stack(
      children: [
        Container(
          color: Colors.white,
          width: Get.width-30,
          height: 90,

          child:  Row(
            children: [

              const Padding(
                padding:  EdgeInsets.only(left: 0,top: 0,right: 15,bottom: 10),
                child: XinHeAssetImage('assets/images/home/tmp.png',width: 80,height: 80,fit: BoxFit.fill,),
              ),

              ///描述与价格数量
              Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  SizedBox(
                      width:Get.width-30-80-30-15,
                      child: Text('一级冷榨有机野山茶籽油500ML级冷榨有机野iii',maxLines: 2,softWrap: true,style: TextStyle(color: XinHeColor('#222222'),fontSize: 14,fontWeight: FontWeight.bold),)
                  ),
                  const SizedBox(height: 10,),



                  SizedBox(
                    width:Get.width-30-80-30-15,
                    height: 23,
                    child: Row(
                      children: [

                        RichText(
                            text: TextSpan(children: [
                              ///￥
                              TextSpan(
                                text: '退款',
                                style: TextStyle(
                                  color:XinHeStyle.mainBalckFontColor,
                                  fontSize: 12,
                                  fontWeight: FontWeight.w500,
                                ),
                              ),
                              ///￥
                              TextSpan(
                                text: '￥',
                                style: TextStyle(
                                  color: XinHeStyle.mainBalckFontColor,
                                  fontSize: 9,
                                  fontWeight: FontWeight.w500,
                                ),
                              ),

                              ///
                              TextSpan(
                                text: '${model.price}',
                                style: TextStyle(
                                  color: XinHeStyle.mainBalckFontColor,
                                  fontSize: 18,
                                  fontWeight: FontWeight.w500,
                                ),
                              ),

                            ]
                            )),
                        const Spacer(),

                        // Text('x${model.count}',style: TextStyle(color: XinHeColor('#8B9191'), fontSize: 12, fontWeight: FontWeight.w500,)),
                        const SizedBox(width: 0,)

                      ],
                    ),
                  )

                ],)


            ],
          ),
        ),

        // Positioned(
        //   bottom: 0,
        //   right: 15,
        //   child: Container(
        //     width: Get.width-30-30,
        //     color: XinHeColor('#E7EEEE'),
        //     height: 0.5,),
        // )

      ],
    );
  }

}
